'use strict';
module.exports = app => {
  const { INTEGER } = app.Sequelize;

  const ArticleView = app.model.define('article_view', {
    user_id: {
      type: INTEGER,
      allowNull: false,
      omment: '用户的ID',
    },
    number: {
      type: INTEGER,
      allowNull: false,
      defaultValue: 1,
      omment: '浏览的次数 默认为1',
    },
    article_id: {
      type: INTEGER,
      allowNull: false,
      comment: '浏览的文章id',
    },

  });

  ArticleView.associate = () => {
    app.model.ArticleView.belongsTo(app.model.Article, { as: 'article', foreignKey: 'article_id' });
  };

  return ArticleView;
};
